// <com.woyouqiu.Copyright>
// --------------------------------------------------------------
// <copyright>上海有求网络科技有限公司 2015</copyright>
// <Solution>MyCompany.MyProject</Solution>
// <Project>MyCompany.MyProject.Core</Project>
// <FileName>Order.cs</FileName>
// <CreateTime>2017-04-22 23:00</CreateTime>
// <Author>何苗</Author>
// <Email>hemiao@woyouqiu.com</Email>
// <log date="2017-04-22 23:00" version="00001">创建</log>
// --------------------------------------------------------------
// </com.woyouqiu.Copyright>

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Abp.Domain.Entities.Auditing;
using Vecen.BangChuang.Authorization.Users;
using Vecen.BangChuang.BangChuang.Agents;

namespace Vecen.BangChuang.BangChuang.Mall {


    /// <summary>
    /// 订单信息
    /// </summary>
    public class Order: FullAuditedEntity {

        /// <summary>
        /// 用户ID
        /// </summary>
        public long UserId { get; set; }

        [ForeignKey(nameof(UserId))]
        public virtual User User { get; set; }

        /// <summary>
        /// 付款方式
        /// </summary>
        public string PaymentMethod { get; set; }

        /// <summary>
        /// 是否已支付
        /// </summary>
        public bool IsPayed { get; set; }
        
        /// <summary>
        /// 是否已作废
        /// </summary>
        public bool IsBlankOut { get; set; }

        /// <summary>
        /// 总价
        /// </summary>
        public decimal Price { get; set; }

        /// <summary>
        /// 订单明细
        /// </summary>

        [ForeignKey(nameof(OrderItem.OrderId))]
        public virtual ICollection<OrderItem> OrderItems { get; set; }

        /// <summary>
        /// 订单备注
        /// </summary>
        [StringLength(512)]
        public string Remark { get; set; }

        /// <summary>
        /// 关联代理ID
        /// </summary>
        public int? AgentId { get; set; }

        /// <summary>
        /// 代理信息
        /// </summary>
        [ForeignKey(nameof(AgentId))]
        public virtual Agent Agent { get; set; }

        /// <summary>
        /// 订单时间
        /// </summary>
        public DateTime OrderTime { get; set; }

        /// <summary>
        /// 收获地址
        /// </summary>
        public int UserAddressId { get; set; }


        /// <summary>
        /// 是否已发货
        /// </summary>
        public bool IsDelivered { get; set; }


        /// <summary>
        /// 是否
        /// </summary>
        public RetrunStatus RetrunStatus { get; set; } = RetrunStatus.NoRetrun;
    }


    /// <summary>
    /// 退货状态
    /// </summary>
    public enum RetrunStatus {
        
        /// <summary>
        /// 未退货
        /// </summary>
        NoRetrun,

        /// <summary>
        /// 已申请
        /// </summary>
        Apply,

        /// <summary>
        /// 已确认
        /// </summary>
        Confirmed,

        /// <summary>
        /// 已发货
        /// </summary>
        Delivered,

        /// <summary>
        /// 退货完成
        /// </summary>
        ReturnComplete

    }
}